<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>招商华软信息有限公司</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<div class="layui-container">
    <div class="layui-row" style="margin:10px auto">
        <blockquote class="layui-elem-quote">自定义导航栏</blockquote>

    </div>
    <div class="layui-row" id="view" style="margin:10px auto">

    </div>
    <div class="layui-row">
        <div class="layui-card">
            <div class="layui-card-header">卡片面板</div>
            <div class="layui-card-body">
                卡片式面板面板通常用于非白色背景色的主体内<br>
                从而映衬出边框投影
            </div>
        </div>


    </div>
</div>
<script id="demo" type="text/html">

    <fieldset class="layui-elem-field">
        <legend><span class="layui-badge layui-bg-cyan">公司常用</span></legend>
        <div class="layui-field-box">
            {{# layui.each(d, function(index, item){ }}
            <button class="layui-btn layui-btn-lg btn-radius layui-btn-green btn-link" data-url="{{item.linkUrl}}">
                <span class="layui-badge layui-bg-green">{{item.linkName}}</span>
            </button>
            {{# }); }}
        </div>
    </fieldset>

</script>
<script src="/static/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form', 'laytpl'], function () {
        var layer = layui.layer
            , form = layui.form, laytpl = layui.laytpl;
        var $ = layui.$;

        $.get("rest/test/table", function (data) {
            data = JSON.parse(data);
            if (data.code != 'error') {
                console.log(data.data);
                var getTpl = demo.innerHTML
                    , view = document.getElementById('view');
                laytpl(getTpl).render(data.data, function (html) {
                    view.innerHTML = html;
                });
            }
        });

        $("#view").on('click', ".btn-link", function () {
            var linkUrl = $(this).attr("data-url");
            window.open(linkUrl, "_blank")
        })


    });
</script>
</body>
</html>
